/*
 * parserfoperator.c
 *
 *  Created on: 2013-5-17
 *      Author: xkaying
 */

#include "parserfoperator.h"
#include "../typedef/function.h"

#include "lexer.h"
#include "parser.h"

Function *ParserFOperator(Lexer *lexer, int isinline)
{
/*
	assert(lexer);
	Function *pfunction;
	pfunction = FOperatorInit(isinline);
	int state;
	state = 0;
	ptoken = LexerGetToken(lexer);
	char *type;
	char *name;
	Declare *pdeclare;
	while (ptoken) {
		switch (state)
		{
			case 0: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_Equl:
					case TokenType_Add:
					case TokenType_Sub:
					case TokenType_Mul:
					case TokenType_Div:
					case TokenType_Mod:
						//二元操作符号 += -= *= /= %=
					case TokenType_EAdd:
					case TokenType_ESub:
					case TokenType_EMul:
					case TokenType_EDiv:
					case TokenType_EMod:
					case TokenType_Inc:
					case TokenType_Dec:
						//移位之类的数据操作 | & ~ ^ << >>
					case TokenType_BitOr:
					case TokenType_BitAnd:
					case TokenType_BitNot:
					case TokenType_BitXor:
					case TokenType_LeftShift:
					case TokenType_RightShift:
					case TokenType_EBitOr:
					case TokenType_EBitAnd:
					case TokenType_EBitXor:
					case TokenType_ELeftShift:
					case TokenType_ERightShift:
						//逻辑操作 || && !
					case TokenType_Or:
					case TokenType_And:
					case TokenType_Not:
						//比较操作符号 > < == >= <= !=
					case TokenType_More:
					case TokenType_Less:
					case TokenType_EE:
					case TokenType_EMore:
					case TokenType_ELess:
					case TokenType_ENot: {
						FunctionAppendName(pfunction, (char*) ptoken->type);
						state = 1;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_IndexStart: {
						state = 10;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser foperator状态机错误.状态%d.\n", state);
				return 0;
			}
			case 10: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_IndexEnd: {
						state = 1;
						FunctionAppendName(pfunction, (char*) TokenType_Index);
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser foperator状态机错误.状态%d.\n", state);
				return 0;
			}
			case 1: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_BracketStart: {
						state = 2;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser function状态机错误.状态%d.\n", state);
				return 0;
			}
			case 2: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_BracketEnd: {
						state = 3;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_Variable: {
						state = 20;
						//input list 读取
						type = ptoken->name;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser function状态机错误.状态%d.\n", state);
				return 0;
			}
			case 20: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_Variable: {
						state = 21;
						name=ptoken->name;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser function状态机错误.状态%d.\n", state);
				return 0;
			}
			case 3: {
				switch (ptoken->type)
				{
					case TokenType_Comment: {
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_End: {
						//表示定义结束
						ptoken = LexerGetToken(lexer);
						return 0;
					}
						//函数实际内容读取
					case TokenType_BlockStart: {
						state = 4;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					case TokenType_Extend: {
						state = 30;
						ptoken = LexerGetToken(lexer);
						continue;
					}
					default: {
						printf("第%d行:错误的符号重载定义.\n", ptoken->line);
						return 0;
					}
				}
				printf("parser function状态机错误.状态%d.\n", state);
				return 0;
			}
		}
	}*/
	return 0;
}
